//
//  MediaViewController.m
//  23-HomeworkPlanet
//
//  Created by dllo on 16/8/13.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "MediaViewController.h"
#import "HeaderView.h"
#import "ExclusiveTableViewCell.h"


@interface MediaViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;

@end

@implementation MediaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(clickLeftBtn:)];
    UISegmentedControl *segment=[[UISegmentedControl alloc]initWithItems:@[@"直播",@"音乐"]];
    segment.frame = CGRectMake(0, 0, 120, 30);
    segment.layer.cornerRadius = 10;
    segment.selectedSegmentIndex = 1;
    segment.layer.borderWidth = 1;
    segment.layer.masksToBounds = YES;
    segment.layer.borderColor = [UIColor whiteColor].CGColor;
    self.navigationItem.titleView=segment;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    UIBarButtonItem *btn0 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"message"] style:UIBarButtonItemStyleDone target:self action:@selector(clickRightBtn:)];
    UIBarButtonItem *btn1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"music"] style:UIBarButtonItemStyleDone target:self action:@selector(clickRightBtn:)];
    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:btn1, btn0, nil];
    [self creatTableView];
}
- (void)creatTableView {
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    HeaderView *headerview = [[HeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height * 0.4)];
    headerview.backgroundColor = [UIColor orangeColor];
    _tableView.tableHeaderView = headerview;
    [_tableView registerClass:[ExclusiveTableViewCell class] forCellReuseIdentifier:@"cell"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 230;
    }else {
    return 150;
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    }
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        ExclusiveTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    
    return cell;
    
}



- (void)clickLeftBtn:(UIBarButtonItem *)sender {
}
- (void)clickRightBtn:(UIBarButtonItem *)sender {
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
